import VueRouter from 'vue-router'
import Vue from 'vue'

import Layout from '@/layout'
import Login from '@/views/login/index'
import Dashboard from '@/views/dashboard'
import agriMonitoring from '@/views/agriMonitoring'
import farmsStock from '@/views/farmsStock'

Vue.use(VueRouter)

export const routes = [
  {
    path: '/shuzhongtian/login',
    component: Login,
    name: '/shuzhongtianlogin'
  },
  {
    path: '/shuzhongtian/mapH5',
    component: () => import('@/views/mapH5')
  },
  {
    path: '/shuzhongtian',
    component: Layout,
    redirect: '/shuzhongtian/dashboard',
    name: 'dashboard',
    children: [
      {
        path: '/shuzhongtian/dashboard',
        component: Dashboard,
        icon: require('@/assets/img/icon_home1.png'),
        checkIcon: require('@/assets/img/check_icon_home1.png'),
        name: '首页'
      },
      {
        path: '/shuzhongtian/agriLand',
        component: () => import('@/views/agriLand'),
        icon: require('@/assets/img/icon_home2.png'),
        checkIcon: require('@/assets/img/check_icon_home2.png'),
        name: '地块管理'
      },
      {
        path: '/shuzhongtian/farmsStock',
        component: farmsStock,
        icon: require('@/assets/img/icon_home3.png'),
        checkIcon: require('@/assets/img/check_icon_home3.png'),
        name: '农资管理'
      },
      {
        path: '/shuzhongtian/dateTime',
        component: () => import('@/views/dateTime'),
        icon: require('@/assets/img/icon_home4.png'),
        checkIcon: require('@/assets/img/check_icon_home4.png'),
        name: '农事计划'
      },
      {
        path: '/shuzhongtian/agriMonitoring',
        component: agriMonitoring,
        icon: require('@/assets/img/icon_home5.png'),
        checkIcon: require('@/assets/img/check_icon_home5.png'),
        name: '农情感知'
      },
      {
        path: '/shuzhongtian/agriMissionList',
        component: () => import('@/views/agriMissionList'),
        icon: require('@/assets/img/icon_home6.png'),
        checkIcon: require('@/assets/img/check_icon_home6.png'),
        name: '农事记录'
      },
      {
        path: '/shuzhongtian/baseInfo',
        component: () => import('@/views/baseInfo'),
        icon: require('@/assets/img/icon_home7.png'),
        checkIcon: require('@/assets/img/check_icon_home7.png'),
        name: '农场信息'
      },
      {
        path: '/shuzhongtian/agriRole',
        component: () => import('@/views/agriRole'),
        icon: require('@/assets/img/icon_home8.png'),
        checkIcon: require('@/assets/img/check_icon_home8.png'),
        name: '员工管理'
      },
      {
        path: '/shuzhongtian/traceability',
        component: () => import('@/views/traceability'),
        icon: require('@/assets/img/icon_home9.png'),
        checkIcon: require('@/assets/img/check_icon_home9.png'),
        name: '溯源码'
      },
      {
        path: '/shuzhongtian/agriLandDetail',
        component: () => import('@/views/agriLandDetail'),
        name: '地块详情',
        meta: {
          routerList: [{
            name: '地块管理',
            to: '/shuzhongtian/agriLand'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/Information',
        component: () => import('@/views/userInfo/Information'),
        name: '个人信息',
        meta: {
          routerList: [{
            name: '首页',
            to: '/shuzhongtian/dashboard'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/password',
        component: () => import('@/views/userInfo/password'),
        name: '账号设置',
        meta: {
          routerList: [{
            name: '首页',
            to: '/shuzhongtian/dashboard'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/phoneChange',
        component: () => import('@/views/userInfo/phoneChange'),
        name: '换绑手机号',
        meta: {
          routerList: [{
            name: '首页',
            to: '/shuzhongtian/dashboard'
          }, {
            name: '账号设置',
            to: '/shuzhongtian/dashboard/password'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/passwordChange',
        component: () => import('@/views/userInfo/passwordChange'),
        name: '修改密码',
        meta: {
          routerList: [{
            name: '首页',
            to: '/shuzhongtian/dashboard'
          }, {
            name: '账号设置',
            to: '/shuzhongtian/dashboard/password'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/history',
        component: () => import('@/views/agriLand/history'),
        name: '历史种植',
        meta: {
          routerList: [{
            name: '地块管理',
            to: '/shuzhongtian/agriLand'
          }, {
            name: '地块名称'
            // to: '/shuzhongtian/agriLandDetail'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/planAdd',
        component: () => import('@/views/dateTime/planAdd'),
        name: '新增计划',
        meta: {
          routerList: [{
            name: '地块管理',
            to: '/shuzhongtian/agriLand'
          }, {
            name: '地块名称'
            // to: '/shuzhongtian/agriLandDetail'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/pick',
        component: () => import('@/views/agriLandDetail/components/pick'),
        name: '采收',
        meta: {
          routerList: [{
            name: '地块管理',
            to: '/shuzhongtian/agriLand'
          }, {
            name: '地块名称'
            // to: '/shuzhongtian/agriLandDetail'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/archives',
        component: () => import('@/views/agriLand/archives'),
        name: '查看档案',
        meta: {
          routerList: [{
            name: '地块管理',
            to: '/shuzhongtian/agriLand'
          }, {
            name: '地块名称'
            // to: '/shuzhongtian/agriLandDetail'
          }, {
            name: '历史种植'
            // to: '/shuzhongtian/dashboard/history'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/dashboard/seedAdd',
        component: () => import('@/views/agriLandDetail/components/seedAdd'),
        name: '添加种养品种',
        meta: {
          routerList: [{
            name: '地块管理',
            to: '/shuzhongtian/agriLand'
          }, {
            name: '地块名称'
            // to: '/shuzhongtian/agriLandDetail'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/agriMissionAdd',
        component: () => import('@/views/agriMissionAdd'),
        name: '添加农事',
        hidden: true
      },
      {
        path: '/shuzhongtian/addLoilReport',
        component: () => import('@/views/addLoilreport'),
        name: '土壤改良',
        hidden: true
      },
      {
        path: '/shuzhongtian/agriRoleAdd',
        component: () => import('@/views/agriRoleAdd'),
        name: '用户新增',
        hidden: true
      },
      {
        path: '/shuzhongtian/agriMissionsEdit',
        component: () => import('@/views/agriLandDetail'),
        name: '地块详情编辑',
        hidden: true
      },
      {
        path: '/shuzhongtian/userInfo',
        component: () => import('@/views/userInfo'),
        name: '用户信息',
        hidden: true
      },
      {
        path: '/shuzhongtian/agriMonitoringDevice',
        component: () => import('@/views/agriMonitoringDevice'),
        name: '农情设备详情',
        hidden: true
      },
      {
        path: '/shuzhongtian/agriMonitoringVideo',
        component: () => import('@/views/agriMonitoringVideo'),
        name: '视频监控',
        hidden: true
      },
      {
        path: '/shuzhongtian/farmsStockStatistics/:pageId',
        component: () => import('@/views/farmsStockStatistics'),
        name: '出入库记录',
        meta: {
          routerList: [{
            name: '农资管理',
            to: '/shuzhongtian/farmsStock'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/farmsStockAdd',
        component: () => import('@/views/farmsStockAdd'),
        name: '农资入库',
        meta: {
          routerList: [{
            name: '农资管理',
            to: '/shuzhongtian/farmsStock'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/farmsStockAddHas',
        component: () => import('@/views/farmsStockAdd'),
        name: '农资入库',
        meta: {
          routerList: [{
            name: '农资管理',
            to: '/shuzhongtian/farmsStock'
          }, {
            name: '出入库记录'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/agriAreaAdd',
        component: () => import('@/views/mapAdd'),
        name: '添加地块',
        meta: {
          routerList: [{
            name: '地块管理',
            to: '/shuzhongtian/agriLand'
          }]
        },
        hidden: true
      },
      {
        path: '/shuzhongtian/devicePictures',
        component: () => import('@/views/devicePiuture'),
        name: '图片展示',
        hidden: true
      },
      {
        path: '/shuzhongtian/traceability/created',
        component: () => import('@/views/traceability/created'),
        name: '溯源码',
        hidden: true
      },
      {
        path: '/shuzhongtian/traceability/bind',
        component: () => import('@/views/traceability/bind'),
        name: '溯源码',
        hidden: true
      }
    ]
  },
  {
    path: '/shuzhongtian/baseInfoCheck',
    component: () => import('@/views/baseInfoCheck'),
    name: '完善用户信息'
  }
]

const router = new VueRouter({ mode: 'history', routes })
// 获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
// 修改原型对象中的push方法
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
